import request from "@/modules/index/utils/request";
import qs from "qs";

const store = {
    state: {
        currentParamId: 0
    },
    mutations: {
        SET_CURRENT_PARAM_ID: (state, currentParamId) => {
            state.currentParamId = currentParamId
        },
    },
    actions: {
        // 算法参数
        // 列表

        async algoParamsList(context) {
            const data = await request({
                url: "algorithmInfo/list",
                method: "get"
            });
            return data;
        },

        // 根据id获取列表
        async algoParamsListById(context, params) {
            const data = await request({
                url: `algorithmInfo/getById?id=${params}`,
                method: "get"
            });
            return data;
        },
        // 分页列表
        async algoParamsPageList(context, params) {
            const data = await request({
                url: params
                    ? `algorithmInfo/pageList?${params}`
                    : "algorithmInfo/pageList",
                method: "get"
            });
            return data;
        },
        // 新增
        async algoParamsListSave(context, params) {
            const data = await request({
                url: "algorithmInfo/save",
                method: "post",
                data: params
            });
            return data;
        },
        // 修改或新增
        async algoParamsListSaveOrUpdate(context, params) {
            const data = await request({
                url: params
                    ? `algorithmInfo/pageList?${params}`
                    : "algorithmInfo/pageList",
                method: "post",
                data: params
            });
            return data;
        },
        // 删除
        async algoParamsListBatchDelete(context, params) {
            const data = await request({
                url: "algorithmInfo/deleteByIds",
                method: "post",
                params: params,
                paramsSerializer: params => {
                    return qs.stringify(params, { indices: false });
                }
            });
            return data;
        },
        // 设备型号
        // 列表

        async equipCatalogList(context) {
            const data = await request({
                url: "equipCatalog/list",
                method: "get"
            });
            return data;
        },

        // 根据id获取列表
        async equipCatalogListById(context, params) {
            const data = await request({
                url: `equipCatalog/getById?id=${params}`,
                method: "get"
            });
            return data;
        },
        // 分页列表
        async equipCatalogPageList(context, params) {
            const data = await request({
                url: params
                    ? `equipCatalog/pageList?${params}`
                    : "equipCatalog/pageList",
                method: "get"
            });
            return data;
        },
        // 新增
        async equipCatalogListSave(context, params) {
            const data = await request({
                url: "equipCatalog/save",
                method: "post",
                data: params
            });
            return data;
        },
        // 修改或新增
        async equipCatalogListSaveOrUpdate(context, params) {
            const data = await request({
                url: params
                    ? `equipCatalog/pageList?${params}`
                    : "equipCatalog/pageList",
                method: "post",
                data: params
            });
            return data;
        },
        // 删除
        async equipCatalogListBatchDelete(context, params) {
            const data = await request({
                url: "equipCatalog/deleteByIds",
                method: "post",
                params: params,
                paramsSerializer: params => {
                    return qs.stringify(params, { indices: false });
                }
            });
            return data;
        },

        // 设备型号参数
        // 列表

        async equipCheckList(context) {
            const data = await request({
                url: "equipCheck/list",
                method: "get"
            });
            return data;
        },

        // 根据id获取列表
        async equipCheckListById(context, params) {
            const data = await request({
                url: `equipCheck/getById?id=${params}`,
                method: "get"
            });
            return data;
        },
        // 分页列表
        async equipCheckPageList(context, params) {
            const data = await request({
                url: params
                    ? `equipCheck/pageList?${params}`
                    : "equipCheck/pageList",
                method: "get"
            });
            return data;
        },
        // 新增
        async equipCheckListSave(context, params) {
            const data = await request({
                url: "equipCheck/save",
                method: "post",
                data: params
            });
            return data;
        },
        // 修改或新增
        async equipCheckListSaveOrUpdate(context, params) {
            const data = await request({
                url: params
                    ? `equipCheck/pageList?${params}`
                    : "equipCheck/pageList",
                method: "post",
                data: params
            });
            return data;
        },
        // 删除
        async equipCheckListBatchDelete(context, params) {
            const data = await request({
                url: "equipCheck/deleteByIds",
                method: "post",
                params: params,
                paramsSerializer: params => {
                    return qs.stringify(params, { indices: false });
                }
            });
            return data;
        }
    }
};

export default store;
